import { 
    getCities,
    getEvent,
} from '@/api/request'
import {fetchTodos} from '@/utils/utils'
import * as actionTypes from './constants'

export const changecitiesList = (data) => ({
    type: actionTypes.CHANGECITIES_LIST,
    data: data
})
export const changeEventsList = (data) => ({
    type:actionTypes.CHANGE_EVENTS_LIST,
    data: data
})
// api请求 一定放在action中 
export const getcitieslist = () => {
    return (dispatch) => {
        console.log('|||||||||||||||')
            getCities()
            .then(item => {
                // console.log(item.data, '////')
                const action = changecitiesList(item.data);
                dispatch(action)
            })
    }
}
export const getEventslist = (data) => {
    return (dispatch) => {
            getEvent()
            .then(item => {
                const result = [...item.data]
                console.log(result,'猪')
                let a = fetchTodos({...data, result})
                // const action = changeEventsList(item.data);
                dispatch(changeEventsList(a))
            })
    }
}